/*******************************************************************************
*                                                                              *
* This file provides functions implementation for a Genetic Algorithm showing  *
* fault tolerence behaviour.                                                   *
*                                                                              *
*******************************************************************************/

#ifndef __FTGA_PLUGIN_H__
#define __FTGA_PLUGIN_H__

////////////////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////////////////

#include "SCSystem.hpp"
#include "SC_FTGA_LibConfig.h"

////////////////////////////////////////////////////////////////////////////////
// Prototypes
////////////////////////////////////////////////////////////////////////////////

/**
 *	Initialises the plugin.
 *	This function is called when a plugin is loaded to initialise some data
 *	(like loading a file) before computation starts.
*/
LIBRARY_DECL void InitPlugin (const std::string &);

/**
 *	Closes the plugin properly.
 *	This function is called when a plugin is closed to finalise some data (like 
 *	closing a file or free memory) when computation ends.
*/
LIBRARY_DECL void ClosePlugin (void);

/**
 *	Initialises a system with a random path if needed and push it into the given
 *	computation space if not done already.
 *	@param sys1 System 1 : Solution
 *	@param context Context system : Initialiser
 *	@param sys2 System 2 : Computation space
*/
LIBRARY_DECL bool Initialise (SC::SCSystem &, const SC::SCSystem &, SC::SCSystem &);

/**
 *	Selection and Evolution operations between two solutions (chromosomes)
 *	The selection involves elitism (the best of the two is kept) and the
 *	evolution is done either by crossover (CO) or by copy and mutation (CP) of
 *	the worse solution.
 *	@param sys1 System 1 : Path holder
 *	@param context Context system : No context requirements
 *	@param sys2 System 2 : Path holder
*/
LIBRARY_DECL bool Operator (SC::SCSystem &, const SC::SCSystem &, SC::SCSystem &);

/**
 *	Transfer the solution if it is better than the universe best known.
 *	@param sys1 System 1 : Solution
 *	@param context Context system : SolTransfer
 *	@param sys2 System 2 : Universe
*/
LIBRARY_DECL bool SolTransfer (SC::SCSystem &, const SC::SCSystem &, SC::SCSystem &);

/**
 *	Law of physics for fault injection
 *	An unexpected phenomenon can cause damage to a system in the context of laws
 *	of physics.
 *	@param sys1 System 1 : An unexepcted phenomenon
 *	@param context Context system : Law of physics
 *	@param sys2 System 2 : Any system
*/
LIBRARY_DECL bool LawsOfPhysics (SC::SCSystem &, const SC::SCSystem &, SC::SCSystem &);

/**
 *	Self-maintenance system
 *	Two systems can attempts to spot and fix damages within each other.
 *	@param sys1 System 1 : A system
 *	@param context Context system : SelfMaintenance
 *	@param sys2 System 2 : Another system
*/
LIBRARY_DECL bool SelfMaintenance (SC::SCSystem &, const SC::SCSystem &, SC::SCSystem &);

/**
 *	Dummy context
 *	@param sys1 System 1 : A system
 *	@param context Context system : DummyContext
 *	@param sys2 System 2 : Another system
*/
LIBRARY_DECL bool Dummy (SC::SCSystem &, const SC::SCSystem &, SC::SCSystem &);

////////////////////////////////////////////////////////////////////////////////

#endif
